import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import DefaultError from '../views/404.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    },
    {
        path: "*",
        name: '404',
        component: DefaultError
    },
    {
        path: "/click",
        name: 'click',
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    },
    //   动态路由
    {
        path: "/user/:userid",
        name: 'user',
        component: () => import(/* webpackChunkName: "about" */ '../views/user.vue') // 路由懒加载写法
    }
]

const router = new VueRouter({
    routes,
    mode: "history", // hash or history
    linkActiveClass: "my-action" // 自定义当前action类的类名
})

export default router
